#include "stdio.h"
#include "string.h"
main()
{
	int data[10001];
	int n,m,i,j;
	int shu,clone;

	scanf("%d%d",&n,&m);
	while (n||m)
	{
		memset(data,0,sizeof(data));
		for (i=1;i<=m;i++,++data[shu])
			scanf("%d",&shu);
		
		clone=0;
		for (i=1;i<=n;i++) 
			if (data[i]>1) clone++;		
		printf("%d\n",clone);
		scanf("%d%d",&n,&m);
	}


}
